# Maintainer: Guillaume Alaux <guillaume@archlinux.org>
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: William Gathoye <william + archlinux at gathoye dot be>
# Contributor: Emanuel Couto <emanuel dot amaral dot couto at gmail dot com>
# Contributor: Richard Jackson <rdjack21 at gmail dot com>
# Contributor: Tinx <arch at tinx dot eu>
# Contributor: Jens Kapitza <j dot kapitza at schwarze-allianz dot de>
# Contributor: Olli <olli at coderkun dot de>

pkgbase=java8-openjfx
pkgname=(
  java8-openjfx
  java8-openjfx-doc
  java8-openjfx-src
)
pkgver=8.u202
pkgrel=3
pkgdesc='Java OpenJFX 8 client application platform (open-source implementation of JavaFX)'
arch=(x86_64)
url=https://wiki.openjdk.java.net/display/OpenJFX/Main
license=(GPL)
makedepends=(
  alsa-lib
  cairo
  cmake
  ffmpeg
  freetype2
  gdk-pixbuf2
  glib2
  gperf
  gtk2
  gtk3
  java-environment-openjdk=8
  libgl
  libx11
  libxtst
  pango
  python2
  qt5-base
  ruby
  unzip
  webkit2gtk
)
source=(
  https://hg.openjdk.java.net/openjfx/8u/rt/archive/${pkgver//./}-ga.tar.bz2
  gradle.properties
  https://services.gradle.org/distributions/gradle-4.8-bin.zip
  java8-openjfx-flags.patch
  java8-openjfx-no-xlocale.patch
)
sha256sums=('12b0538d04c4bd451e4692ee06357ac36233ff4ec2af9fa3b9bbdbab48c3f2fc'
            '75335ac8ccae143ab4dbb81fc32c70d34d95baa360388f55bf2d237e8821ad97'
            'f3e29692a8faa94eb0b02ebf36fa263a642b3ae8694ef806c45c345b8683f1ba'
            '867badaca506f130f918bdc620ae7ae5be8b176fcdfc91fef551b636d6390b19'
            'b21f6b254acc7aa2124521b6521d3bdfdfcfd9b062624a84ef73608120957d0d')

prepare() {
  cd rt-${pkgver//./}-ga

  ln -sf ../gradle.properties .
  patch -Np1 -i ../java8-openjfx-flags.patch
  patch -Np1 -i ../java8-openjfx-no-xlocale.patch
}

build() {
  cd rt-${pkgver//./}-ga

  ../gradle-4.8/bin/gradle
}

package_java8-openjfx() {
  depends=(
    alsa-lib
    cairo
    ffmpeg
    gdk-pixbuf2
    glib2
    gtk2
    gtk3
    java-runtime-openjdk=8
    libavcodec.so
    libavformat.so
    libfreetype.so
    libgl
    libx11
    libxtst
    pango
    python2
    qt5-base
    ruby
    unzip
    webkit2gtk
  )

  cd rt-${pkgver//./}-ga

  install -dm 755  "${pkgdir}"/usr/lib/jvm/java-8-openjdk/jre
  cp -dr --no-preserve=ownership build/sdk/{bin,lib} "${pkgdir}"/usr/lib/jvm/java-8-openjdk/
  cp -dr --no-preserve=ownership build/sdk/rt/lib "${pkgdir}"/usr/lib/jvm/java-8-openjdk/jre/
}

package_java8-openjfx-doc() {
  cd rt-${pkgver//./}-ga

  install -dm 755 "${pkgdir}"/usr/share/doc
  cp -dr --no-preserve=ownership build/javadoc "${pkgdir}"/usr/share/doc/java8-openjfx
}

package_java8-openjfx-src() {
  cd rt-${pkgver//./}-ga

  install -Dm 644 build/javafx-src.zip -t "${pkgdir}"/usr/lib/jvm/java-8-openjdk/
}

# vim: ts=2 sw=2 et:
